//
//  SickInfoCell.m
//  掌上宏力
//
//  Created by admin on 2017/6/6.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "SickInfoCell.h"
#import "SickInfoModel.h"
#import "SickInfoFrame.h"

@interface SickInfoCell()

@property (nonatomic,weak) UILabel *nameL;
@property (nonatomic,weak) UILabel *zhusuL;
@property (nonatomic,weak) UILabel *historyL;
@property (nonatomic,weak) UILabel *healthyL;
@property (nonatomic,weak) UILabel *westernL;
@property (nonatomic,weak) UILabel *easternL;

@property (nonatomic,weak) UILabel *nameLab;
@property (nonatomic,weak) UILabel *zhusuLab;
@property (nonatomic,weak) UILabel *historyLab;
@property (nonatomic,weak) UILabel *healthyLab;
@property (nonatomic,weak) UILabel *westernLab;
@property (nonatomic,weak) UILabel *easternLab;
@property (nonatomic,weak) UIView *view;

@end

static CGFloat left_dis = 10;

@implementation SickInfoCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        UIView *view = [[UIView alloc] init];
        view.backgroundColor = [UIColor whiteColor];
        view.layer.cornerRadius = 5;
        [self.contentView addSubview:view];
        self.view = view;
        
        NSArray *titles = @[@"姓        名:",@"主        诉:",@"现  病  史:",@"体        检:",@"西医诊断:",@"中医诊断:"];
        UILabel *nameL = [self createLabWithTitle:titles[0] Font:15];
        [view addSubview:nameL];
        self.nameL = nameL;
        UILabel *nameLab = [self createLabWithFont:15];
        [view addSubview:nameLab];
        self.nameLab = nameLab;
        
        UILabel *zhusuL = [self createLabWithTitle:titles[1] Font:15];
        [view addSubview:zhusuL];
        self.zhusuL = zhusuL;
        UILabel *zhusuLab = [self createLabWithFont:15];
        [view addSubview:zhusuLab];
        self.zhusuLab = zhusuLab;
        
        UILabel *historyL = [self createLabWithTitle:titles[2] Font:15];
        [view addSubview:historyL];
        self.historyL = historyL;
        UILabel *historyLab = [self createLabWithFont:15];
        [view addSubview:historyLab];
        self.historyLab = historyLab;
        
        UILabel *healthyL = [self createLabWithTitle:titles[3] Font:15];
        [view addSubview:healthyL];
        self.healthyL = healthyL;
        UILabel *healthyLab = [self createLabWithFont:15];
        healthyLab.numberOfLines = 0;
        [view addSubview:healthyLab];
        self.healthyLab = healthyLab;
        
        UILabel *westernL = [self createLabWithTitle:titles[4] Font:15];
        [view addSubview:westernL];
        self.westernL = westernL;
        UILabel *westernLab = [self createLabWithFont:15];
        westernLab.numberOfLines = 0;
        [view addSubview:westernLab];
        self.westernLab = westernLab;
        
        UILabel *easternL = [self createLabWithTitle:titles[5] Font:15];
        [view addSubview:easternL];
        self.easternL = easternL;
        UILabel *easternLab = [self createLabWithFont:15];
        [view addSubview:easternLab];
        self.easternLab = easternLab;
        
    }
    return self;
}
-(UILabel *)createLabWithFont:(CGFloat)font{
    return [self createLabWithTitle:@"" Font:font];
}
-(UILabel *)createLabWithTitle:(NSString *)title Font:(CGFloat)font{
    UILabel *lab = [[UILabel alloc] init];
    lab.font = [UIFont systemFontOfSize:font];
    lab.text = title;
    return lab;
}
-(void)setSickInfoF:(SickInfoFrame *)sickInfoF{
    _sickInfoF = sickInfoF;
    [self settingData];
    [self settingFrame];
}
-(void)settingData{
    SickInfoModel *sickInfo = _sickInfoF.sickInfo;
    self.nameLab.text = sickInfo.name;
    self.zhusuLab.text = sickInfo.zhusu;
    self.historyLab.text = sickInfo.history;
    self.healthyLab.text = sickInfo.healthy;
    self.westernLab.text = [sickInfo.western isEqualToString:@""]? @"无": sickInfo.western;
    self.easternLab.text = [sickInfo.eastern isEqualToString:@""]? @"无":sickInfo.eastern;
}
-(void)settingFrame{
    self.nameL.frame = _sickInfoF.nameF;
    self.nameLab.frame = _sickInfoF.nameLabF;
    self.zhusuL.frame = _sickInfoF.zhusuF;
    self.zhusuLab.frame = _sickInfoF.zhusuLabF;
    self.historyL.frame = _sickInfoF.historyF;
    self.historyLab.frame = _sickInfoF.historyLabF;
    self.healthyL.frame = _sickInfoF.healthyF;
    self.healthyLab.frame = _sickInfoF.healthyLabF;
    self.westernL.frame = _sickInfoF.westernF;
    self.westernLab.frame = _sickInfoF.westernLabF;
    self.easternL.frame = _sickInfoF.easternF;
    self.easternLab.frame = _sickInfoF.easternLabF;
    self.view.frame = CGRectMake(left_dis, 0, kScreenW-left_dis*2, _sickInfoF.cellHeight);
    
}

+(instancetype)cellWithTableView:(UITableView *)tableView{
    static NSString *cellId = @"cellId";
    SickInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    if (cell == nil) {
        cell = [[SickInfoCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.backgroundColor = [UIColor clearColor];
    return cell;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
